********************************************************************************
*** Scrum Retro-Survey *********************************************************
*** Do-file to create graphs for the paper: 
*** "Introducting ScrumAdemia: An Agile Guide for Doctoral Research"

* Stata 15.1
* Rebecca Lohmann, 17.11.2022

* This script will:
* 	load the data set (stata dataset)
* 	create the graphs

********************************************************************************
clear all
set more off
capture log close

********************************************************************************
global dta		"YOUR\FILE\PATH"
********************************************************************************
* Figure 1 - Satisfaction
use "$dta/dta_clean.dta", clear

tab sprintnumber
tab satisfaction

keep if sprintnumber <= 31 //we will use only data until october 2021

collapse (mean) satisfaction , by(sprintnumber)

capture graph drop _all


twoway (line satisfaction sprintnumber, xlab(11(1)31, alternate) ///
				xtitle("Sprint Number") ///
				yscale(range(1/5)) ///
				ylab(1 "Very dissatisfied" 2 "Somewhat dissatisfied" 3 "Neither satisfied nor dissatisfied"  4 "Somewhat satisfied" 5 "Very satisfied", angle(horizontal)) ///
				yline(3) ///
				ytitle("Satisfaction (mean)") ///
				note(average N per Sprint = 5) ///
				graphregion(color(white)) ///
				scheme(sj))
			
				
*** Figure 2 - Success
use "$dta/dta_clean.dta", clear

keep if sprintnumber <= 31 //we will use only data until october 2021

list sprintnumber successOth success_2 if successOth!="" 
replace success_2 = 1 if substr(successOth, 1, 14)=="I accomplished"| substr(successOth, 1, 9)=="Got a lot" | substr(successOth, 1, 7)=="Success"
replace success_3 = 1 if substr(successOth, 1, 6)=="talked"

stack success_*, into(success) clear

la def successl 1 "All accomplished" 2 "Met deadline / concluded something" 3 "Good feedback" 4 "Feeling of satisfaction" 5 "Feeling inspired"
la val _stack successl

splitvallabels _stack
graph hbar (count) success if success!=0 & _stack<6, over(_stack, relabel(`r(relabel)')) ///
				bar(1, color(gs10) lcolor(gs5)) ///
				graphregion(color(white)) ///
				ytitle("count (over 20 Sprints)")
				
*** Figure 3 - Challenges
use "$dta/dta_clean.dta", clear

keep if sprintnumber <= 31 //we will use only data until october 2021

list challengeOth Challenge_1 Challenge_2 if challengeOth!="" 
replace Challenge_1 = 1 if substr(challengeOth, 1, 5)=="Cours"
replace Challenge_5 = 1 if substr(challengeOth, 1, 5)=="Despi"

stack Challenge_*, into(challenge) clear 

la def challengel 1 "Misjudged time needs" 2 "Unexpected work-related tasks" 3 "Dependency on others" 4 "Procrastination" 5 "Items/goals not well defined" 6 "Unexpected private distractions" 7 "Expected private distractions" 
la val _stack challengel

splitvallabels _stack
graph hbar (count) challenge if challenge!=0 & _stack<8, over(_stack, relabel(`r(relabel)') sort(1) descending) ///
				bar(1, color(gs10) lcolor(gs5)) ///
				graphregion(color(white)) ///
				ytitle("count (over 20 Sprints)")
				




